package com.eryos.android.cigarettecounter.ui;

/**
 * Project :  CigaretteCounter
 * Author :   Olivier Combe 
 * URL :      http://eryos.fr/CigaretteCounter/
 *
 * Copyright (C) 2011 - Olivier Combe 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *
 */

import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

import com.eryos.android.cigarettecounter.R;
import com.eryos.android.cigarettecounter.charts.Chart;

public class ChartPopup extends Dialog{

	private ImageView chartFullScreen;
	
	public ChartPopup(Context context) {
		super(context);		
	}
	
	public ChartPopup(Context context, String title, String chartURL) {
		this(context);
		
		this.setContentView(R.layout.chart_dialog);
		this.setTitle(title);

		chartFullScreen = (ImageView) findViewById(R.id.popup_image);		
    	chartFullScreen.setImageDrawable(context.getResources().getDrawable(R.drawable.eryos));
    	Log.i("Chart URL", chartURL);
		Bitmap bmp = Chart.downloadChartAsBitmap(this.getContext(), chartURL);
		chartFullScreen.setImageBitmap(bmp);
		
		this.show();
		
		chartFullScreen.setOnTouchListener(new OnTouchListener() {
  			public boolean onTouch(View v, MotionEvent event) {
				dismiss();
				return false;
			}
        });
	}	

}
